package com.graduation.springbootinit.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.graduation.springbootinit.model.entity.CulturePart.CulturePartDiscussion;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.data.domain.Page;

/**
 * 文化讨论区数据库操作
 */
@Mapper
public interface CulturePartDiscussionMapper extends BaseMapper<CulturePartDiscussion> {
    
    /**
     * 增加浏览次数
     */
    @Select("UPDATE culture_part_discussions SET view_count = view_count + 1 WHERE id = #{id}")
    void incrementViewCount(@Param("id") Long id);
    
    /**
     * 增加评论数
     */
    @Select("UPDATE culture_part_discussions SET comment_count = comment_count + 1 WHERE id = #{id}")
    void incrementCommentCount(@Param("id") Long id);
    
    /**
     * 分页查询讨论列表
     */
    Page<CulturePartDiscussion> selectPage(Page<CulturePartDiscussion> page, @Param("queryWrapper") QueryWrapper<CulturePartDiscussion> queryWrapper);
}